import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import user from './modules/user'
import store from './modules/store'
Vue.use(Vuex)

//集中管理多个组件共享数据
export default new Vuex.Store({
    //数据，状态
    state:{
        //模板中：{{$store.state.xxx}}
        //组件逻辑中：this.$store.state.xxx
        //js模块中：store.state.xxx
        menu_active:1,
        carousel_index:1,
        //左侧栏
        isCollapse:false,
        orderActive:'first'
    },
    getters:{
        token(state){
            return state.user.userInfo.token
        },
        userInfo(state){
            return state.user.userInfo
        }
    },
    //修改共享数据，必须是同步操作
    mutations:{

    },
    //异步操作
    actions:{

    },
    modules:{
        user,
        store
    }
})